package org.bigdata.framework.core.protocol.impl;

import org.bigdata.framework.core.mapper.LogMapper;
import org.bigdata.framework.core.model.Advertisement;
import org.bigdata.framework.core.model.Answer;
import org.bigdata.framework.core.model.Audit;
import org.bigdata.framework.core.model.Browse;
import org.bigdata.framework.core.model.Category;
import org.bigdata.framework.core.model.ClassesOnline;
import org.bigdata.framework.core.model.ClassesOnlineComment;
import org.bigdata.framework.core.model.Collect;
import org.bigdata.framework.core.model.Comment;
import org.bigdata.framework.core.model.Config;
import org.bigdata.framework.core.model.Course;
import org.bigdata.framework.core.model.CourseComment;
import org.bigdata.framework.core.model.CourseQuestion;
import org.bigdata.framework.core.model.Live;
import org.bigdata.framework.core.model.LiveQuestion;
import org.bigdata.framework.core.model.Log;
import org.bigdata.framework.core.model.Member;
import org.bigdata.framework.core.model.Menu;
import org.bigdata.framework.core.model.Message;
import org.bigdata.framework.core.model.Online;
import org.bigdata.framework.core.model.OnlineQuestion;
import org.bigdata.framework.core.model.Order;
import org.bigdata.framework.core.model.Paper;
import org.bigdata.framework.core.model.Permission;
import org.bigdata.framework.core.model.Question;
import org.bigdata.framework.core.model.QuestionDatabase;
import org.bigdata.framework.core.model.Role;
import org.bigdata.framework.core.model.ShortFilm;
import org.bigdata.framework.core.model.ShortFilmComment;
import org.bigdata.framework.core.model.User;
import org.bigdata.framework.core.model.UserRole;
import org.bigdata.framework.core.protocol.IBaseService;
import org.bigdata.framework.core.service.IAdvertisementService;
import org.bigdata.framework.core.service.IAnswerService;
import org.bigdata.framework.core.service.IAuditService;
import org.bigdata.framework.core.service.IBrowseService;
import org.bigdata.framework.core.service.ICategoryService;
import org.bigdata.framework.core.service.IClassesOnlineCommentService;
import org.bigdata.framework.core.service.IClassesOnlineService;
import org.bigdata.framework.core.service.ICollectService;
import org.bigdata.framework.core.service.ICommentService;
import org.bigdata.framework.core.service.IConfigService;
import org.bigdata.framework.core.service.ICourseCommentService;
import org.bigdata.framework.core.service.ICourseQuestionService;
import org.bigdata.framework.core.service.ICourseService;
import org.bigdata.framework.core.service.ILiveQuestionService;
import org.bigdata.framework.core.service.ILiveService;
import org.bigdata.framework.core.service.ILogService;
import org.bigdata.framework.core.service.IMemberService;
import org.bigdata.framework.core.service.IMenuService;
import org.bigdata.framework.core.service.IMessageService;
import org.bigdata.framework.core.service.IOnlineQuestionService;
import org.bigdata.framework.core.service.IOnlineService;
import org.bigdata.framework.core.service.IOrderService;
import org.bigdata.framework.core.service.IPaperService;
import org.bigdata.framework.core.service.IPermissionService;
import org.bigdata.framework.core.service.IQuestionDatabaseService;
import org.bigdata.framework.core.service.IQuestionService;
import org.bigdata.framework.core.service.IRoleService;
import org.bigdata.framework.core.service.IShortFilmCommentService;
import org.bigdata.framework.core.service.IShortFilmService;
import org.bigdata.framework.core.service.IUserRoleService;
import org.bigdata.framework.core.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BaseService implements IBaseService {

	@Autowired
	private IUserService userService;
	@Autowired
	private IUserRoleService userRoleService;
	@Autowired
	private IRoleService roleService;
	@Autowired
	private IMenuService menuService;
	@Autowired
	private IPermissionService permissionService;
	@Autowired
	private IAdvertisementService advertisementService;
	@Autowired
	private IBrowseService browseService;
	@Autowired
	private ICategoryService categoryService;
	@Autowired
	private IClassesOnlineService classesOnlineService;
	@Autowired
	private IClassesOnlineCommentService classesOnlineCommentService;
	@Autowired
	private ICollectService collectService;
	@Autowired
	private ICommentService commentService;
	@Autowired
	private IConfigService configService;
	@Autowired
	private ICourseService courseService;
	@Autowired
	private ICourseQuestionService courseQuestionService;
	@Autowired
	private ICourseCommentService courseCommentService;
	@Autowired
	private ILiveService liveService;
	@Autowired
	private ILiveQuestionService liveQuestionService;
	@Autowired
	private ILogService logService;
	@Autowired
	private IMemberService memberService;
	@Autowired
	private IMessageService messageService;
	@Autowired
	private IOnlineService onlineService;
	@Autowired
	private IOnlineQuestionService onlineQuestionService;
	@Autowired
	private IOrderService orderService;
	@Autowired
	private IQuestionService questionService;
	@Autowired
	private IQuestionDatabaseService questionDatabaseService;
	@Autowired
	private IShortFilmService shortFilmService;
	@Autowired
	private IShortFilmCommentService shortFilmCommentService;
	@Autowired
	private IPaperService paperService;
	@Autowired
	private IAnswerService answerService;
	@Autowired
	private IAuditService auditService;
	@Autowired
	private LogMapper logMapper;
	
	@Override
	public User saveUser(User user) {
		boolean r = userService.insert(user);
		if (r) {
			return user;
		}
		return null;
	}

	@Override
	public User editUser(User user) {
		boolean r = userService.updateAllColumnById(user);
		if (r) {
			return user;
		}
		return null;
	}

	@Override
	public void deleteUser(User user) {
		boolean r = userService.deleteById(user.getId());
		if (r) {
			System.out.println("user 删除成功>>>" + user.getId());
		}

	}

	@Override
	public Role saveRole(Role role) {
		boolean r = roleService.insert(role);
		if (r) {
			return role;
		}
		return null;
	}

	@Override
	public Role editRole(Role role) {
		boolean r = roleService.updateAllColumnById(role);
		if (r) {
			return role;
		}
		return null;
	}

	@Override
	public void deleteRole(Role role) {
		boolean r = roleService.deleteById(role.getId());
		if (r) {
			System.out.println("role 删除成功>>>" + role.getId());
		}

	}

	@Override
	public Menu saveMenu(Menu menu) {
		boolean r = menuService.insert(menu);
		if (r) {
			return menu;
		}
		return null;
	}

	@Override
	public Menu editMenu(Menu menu) {
		boolean r = menuService.updateAllColumnById(menu);
		if (r) {
			return menu;
		}
		return null;
	}

	@Override
	public void deleteMenu(Menu menu) {
		boolean r = menuService.deleteById(menu.getId());
		if (r) {
			System.out.println("menu 删除成功>>>" + menu.getId());
		}

	}


	@Override
	public UserRole saveUserRole(UserRole userRole) {

		boolean r = userRoleService.insert(userRole);
		if (r) {
			return userRole;
		}
		return null;
	}

	@Override
	public UserRole editUserRole(UserRole userRole) {

		boolean r = userRoleService.updateAllColumnById(userRole);
		if (r) {
			return userRole;
		}
		return null;
	}

	@Override
	public void deleteUserRole(UserRole userRole) {

		boolean r = userRoleService.deleteById(userRole.getId());
		if (r) {
			System.out.println("userRole 删除成功>>>" + userRole.getId());
		}

	}


	@Override
	public Permission savePermission(Permission permission) {

		boolean r = permissionService.insert(permission);
		if (r) {
			return permission;
		}
		return null;
	}

	@Override
	public Permission editPermission(Permission permission) {

		boolean r = permissionService.updateAllColumnById(permission);
		if (r) {
			return permission;
		}
		return null;
	}

	@Override
	public void deletePermission(Permission permission) {

		boolean r = permissionService.deleteById(permission.getId());
		if (r) {
			System.out.println("permission 删除成功>>>" + permission.getId());
		}

	}

	@Override
	public Advertisement saveAdvertisement(Advertisement advertisement) {
		boolean r = advertisementService.insert(advertisement);
		if (r) {
			return advertisement;
		}
		return null;
	}

	@Override
	public Advertisement editAdvertisement(Advertisement advertisement) {
		boolean r = advertisementService.updateAllColumnById(advertisement);
		if (r) {
			return advertisement;
		}
		return null;
	}

	@Override
	public void deleteAdvertisement(Advertisement advertisement) {
		boolean r = advertisementService.deleteById(advertisement.getId());
		if (r) {
			System.out.println("advertisement 删除成功>>>" + advertisement.getId());
		}
	}

	@Override
	public Browse saveBrowse(Browse browse) {
		boolean r = browseService.insert(browse);
		if (r) {
			return browse;
		}
		return null;
	}

	@Override
	public Browse editBrowse(Browse browse) {
		boolean r = browseService.updateAllColumnById(browse);
		if (r) {
			return browse;
		}
		return null;
	}

	@Override
	public void deleteBrowse(Browse browse) {
		boolean r = browseService.deleteById(browse.getId());
		if (r) {
			System.out.println("browse 删除成功>>>" + browse.getId());
		}
	}

	@Override
	public Category saveCategory(Category category) {
		boolean r = categoryService.insert(category);
		if (r) {
			return category;
		}
		return null;
	}

	@Override
	public Category editCategory(Category category) {
		boolean r = categoryService.updateAllColumnById(category);
		if (r) {
			return category;
		}
		return null;
	}

	@Override
	public void deleteCategory(Category category) {
		boolean r = categoryService.deleteById(category.getId());
		if (r) {
			System.out.println("category 删除成功>>>" + category.getId());
		}
	}

	@Override
	public ClassesOnline saveClassesOnline(ClassesOnline classesOnline) {
		boolean r = classesOnlineService.insert(classesOnline);
		if (r) {
			return classesOnline;
		}
		return null;
	}

	@Override
	public ClassesOnline editClassesOnline(ClassesOnline classesOnline) {
		boolean r = classesOnlineService.updateAllColumnById(classesOnline);
		if (r) {
			return classesOnline;
		}
		return null;
	}

	@Override
	public void deleteClassesOnline(ClassesOnline classesOnline) {
		boolean r = classesOnlineService.deleteById(classesOnline.getId());
		if (r) {
			System.out.println("classesOnline 删除成功>>>" + classesOnline.getId());
		}
	}

	@Override
	public ClassesOnlineComment saveClassesOnlineComment(ClassesOnlineComment classesOnlineComment) {
		boolean r = classesOnlineCommentService.insert(classesOnlineComment);
		if (r) {
			return classesOnlineComment;
		}
		return null;
	}

	@Override
	public ClassesOnlineComment editClassesOnlineComment(ClassesOnlineComment classesOnlineComment) {
		boolean r = classesOnlineCommentService.updateAllColumnById(classesOnlineComment);
		if (r) {
			return classesOnlineComment;
		}
		return null;
	}

	@Override
	public void deleteClassesOnlineComment(ClassesOnlineComment classesOnlineComment) {
		boolean r = classesOnlineCommentService.deleteById(classesOnlineComment.getId());
		if (r) {
			System.out.println("classesOnlineComment 删除成功>>>" + classesOnlineComment.getId());
		}
	}

	@Override
	public Collect saveCollect(Collect collect) {
		boolean r = collectService.insert(collect);
		if (r) {
			return collect;
		}
		return null;
	}

	@Override
	public Collect editCollect(Collect collect) {
		boolean r = collectService.updateAllColumnById(collect);
		if (r) {
			return collect;
		}
		return null;
	}

	@Override
	public void deleteCollect(Collect collect) {
		boolean r = collectService.deleteById(collect.getId());
		if (r) {
			System.out.println("collect 删除成功>>>" + collect.getId());
		}
	}

	@Override
	public Comment saveComment(Comment comment) {
		boolean r = commentService.insert(comment);
		if (r) {
			return comment;
		}
		return null;
	}

	@Override
	public Comment editComment(Comment comment) {
		boolean r = commentService.updateAllColumnById(comment);
		if (r) {
			return comment;
		}
		return null;
	}

	@Override
	public void deleteComment(Comment comment) {
		boolean r = commentService.deleteById(comment.getId());
		if (r) {
			System.out.println("comment 删除成功>>>" + comment.getId());
		}
	}

	@Override
	public Config saveConfig(Config config) {
		boolean r = configService.insert(config);
		if (r) {
			return config;
		}
		return null;
	}

	@Override
	public Config editConfig(Config config) {
		boolean r = configService.updateAllColumnById(config);
		if (r) {
			return config;
		}
		return null;
	}

	@Override
	public void deleteConfig(Config config) {
		boolean r = configService.deleteById(config.getId());
		if (r) {
			System.out.println("config 删除成功>>>" + config.getId());
		}
	}

	@Override
	public Course saveCourse(Course course) {
		boolean r = courseService.insert(course);
		if (r) {
			return course;
		}
		return null;
	}

	@Override
	public Course editCourse(Course course) {
		boolean r = courseService.updateAllColumnById(course);
		if (r) {
			return course;
		}
		return null;
	}

	@Override
	public void deleteCourse(Course course) {
		boolean r = courseService.deleteById(course.getId());
		if (r) {
			System.out.println("course 删除成功>>>" + course.getId());
		}
	}

	@Override
	public CourseComment saveCourseComment(CourseComment courseComment) {
		boolean r = courseCommentService.insert(courseComment);
		if (r) {
			return courseComment;
		}
		return null;
	}

	@Override
	public CourseComment editCourseComment(CourseComment courseComment) {
		boolean r = courseCommentService.updateAllColumnById(courseComment);
		if (r) {
			return courseComment;
		}
		return null;
	}

	@Override
	public void deleteCourseComment(CourseComment courseComment) {
		boolean r = courseCommentService.deleteById(courseComment.getId());
		if (r) {
			System.out.println("courseComment 删除成功>>>" + courseComment.getId());
		}
	}

	@Override
	public CourseQuestion saveCourseQuestion(CourseQuestion courseQuestion) {
		boolean r = courseQuestionService.insert(courseQuestion);
		if (r) {
			return courseQuestion;
		}
		return null;
	}

	@Override
	public CourseQuestion editCourseQuestion(CourseQuestion courseQuestion) {
		boolean r = courseQuestionService.updateAllColumnById(courseQuestion);
		if (r) {
			return courseQuestion;
		}
		return null;
	}

	@Override
	public void deleteCourseQuestion(CourseQuestion courseQuestion) {
		boolean r = courseQuestionService.deleteById(courseQuestion.getId());
		if (r) {
			System.out.println("courseQuestion 删除成功>>>" + courseQuestion.getId());
		}
	}

	@Override
	public Live saveLive(Live live) {
		boolean r = liveService.insert(live);
		if (r) {
			return live;
		}
		return null;
	}

	@Override
	public Live editLive(Live live) {
		boolean r = liveService.updateAllColumnById(live);
		if (r) {
			return live;
		}
		return null;
	}

	@Override
	public void deleteLive(Live live) {
		boolean r = liveService.deleteById(live.getId());
		if (r) {
			System.out.println("live 删除成功>>>" + live.getId());
		}
	}

	@Override
	public LiveQuestion saveLiveQuestion(LiveQuestion liveQuestion) {
		boolean r = liveQuestionService.insert(liveQuestion);
		if (r) {
			return liveQuestion;
		}
		return null;
	}

	@Override
	public LiveQuestion editLiveQuestion(LiveQuestion liveQuestion) {
		boolean r = liveQuestionService.updateAllColumnById(liveQuestion);
		if (r) {
			return liveQuestion;
		}
		return null;
	}

	@Override
	public void deleteLiveQuestion(LiveQuestion liveQuestion) {
		boolean r = liveQuestionService.deleteById(liveQuestion.getId());
		if (r) {
			System.out.println("liveQuestion 删除成功>>>" + liveQuestion.getId());
		}
	}

	@Override
	public Log saveLog(Log log) {
		boolean r = logService.insert(log);
		if (r) {
			return log;
		}
		return null;
	}

	@Override
	public Log editLog(Log log) {
		boolean r = logService.updateAllColumnById(log);
		if (r) {
			return log;
		}
		return null;
	}

	@Override
	public void deleteLog(Log log) {
		boolean r = logService.deleteById(log.getId());
		if (r) {
			System.out.println("log 删除成功>>>" + log.getId());
		}
	}

	@Override
	public Member saveMember(Member member) {
		boolean r = memberService.insert(member);
		if (r) {
			return member;
		}
		return null;
	}

	@Override
	public Member editMember(Member member) {
		boolean r = memberService.updateAllColumnById(member);
		if (r) {
			return member;
		}
		return null;
	}

	@Override
	public void deleteMember(Member member) {
		boolean r = memberService.deleteById(member.getId());
		if (r) {
			System.out.println("member 删除成功>>>" + member.getId());
		}
	}

	@Override
	public Message saveMessage(Message message) {
		boolean r = messageService.insert(message);
		if (r) {
			return message;
		}
		return null;
	}

	@Override
	public Message editMessage(Message message) {
		boolean r = messageService.updateAllColumnById(message);
		if (r) {
			return message;
		}
		return null;
	}

	@Override
	public void deleteMessage(Message message) {
		boolean r = messageService.deleteById(message.getId());
		if (r) {
			System.out.println("message 删除成功>>>" + message.getId());
		}
	}

	@Override
	public Online saveOnline(Online online) {
		boolean r = onlineService.insert(online);
		if (r) {
			return online;
		}
		return null;
	}

	@Override
	public Online editOnline(Online online) {
		boolean r = onlineService.updateAllColumnById(online);
		if (r) {
			return online;
		}
		return null;
	}

	@Override
	public void deleteOnline(Online online) {
		boolean r = onlineService.deleteById(online.getId());
		if (r) {
			System.out.println("online 删除成功>>>" + online.getId());
		}
	}

	@Override
	public OnlineQuestion saveOnlineQuestion(OnlineQuestion onlineQuestion) {
		boolean r = onlineQuestionService.insert(onlineQuestion);
		if (r) {
			return onlineQuestion;
		}
		return null;
	}

	@Override
	public OnlineQuestion editOnlineQuestion(OnlineQuestion onlineQuestion) {
		boolean r = onlineQuestionService.updateAllColumnById(onlineQuestion);
		if (r) {
			return onlineQuestion;
		}
		return null;
	}

	@Override
	public void deleteOnlineQuestion(OnlineQuestion onlineQuestion) {
		boolean r = onlineQuestionService.deleteById(onlineQuestion.getId());
		if (r) {
			System.out.println("onlineQuestion 删除成功>>>" + onlineQuestion.getId());
		}
	}

	@Override
	public Order saveOrder(Order order) {
		boolean r = orderService.insert(order);
		if (r) {
			return order;
		}
		return null;
	}

	@Override
	public Order editOrder(Order order) {
		boolean r = orderService.updateAllColumnById(order);
		if (r) {
			return order;
		}
		return null;
	}

	@Override
	public void deleteOrder(Order order) {
		boolean r = orderService.deleteById(order.getId());
		if (r) {
			System.out.println("order 删除成功>>>" + order.getId());
		}
	}

	@Override
	public Question saveQuestion(Question question) {
		boolean r = questionService.insert(question);
		if (r) {
			return question;
		}
		return null;
	}

	@Override
	public Question editQuestion(Question question) {
		boolean r = questionService.updateAllColumnById(question);
		if (r) {
			return question;
		}
		return null;
	}

	@Override
	public void deleteQuestion(Question question) {
		boolean r = questionService.deleteById(question.getId());
		if (r) {
			System.out.println("question 删除成功>>>" + question.getId());
		}
	}

	@Override
	public QuestionDatabase saveQuestionDatabase(QuestionDatabase questionDatabase) {
		boolean r = questionDatabaseService.insert(questionDatabase);
		if (r) {
			return questionDatabase;
		}
		return null;
	}

	@Override
	public QuestionDatabase editQuestionDatabase(QuestionDatabase questionDatabase) {
		boolean r = questionDatabaseService.updateAllColumnById(questionDatabase);
		if (r) {
			return questionDatabase;
		}
		return null;
	}

	@Override
	public void deleteQuestionDatabase(QuestionDatabase questionDatabase) {
		boolean r = questionDatabaseService.deleteById(questionDatabase.getId());
		if (r) {
			System.out.println("questionDatabase 删除成功>>>" + questionDatabase.getId());
		}
	}

	@Override
	public ShortFilm saveShortFilm(ShortFilm shortFilm) {
		boolean r = shortFilmService.insert(shortFilm);
		if (r) {
			return shortFilm;
		}
		return null;
	}

	@Override
	public ShortFilm editShortFilm(ShortFilm shortFilm) {
		boolean r = shortFilmService.updateAllColumnById(shortFilm);
		if (r) {
			return shortFilm;
		}
		return null;
	}

	@Override
	public void deleteShortFilm(ShortFilm shortFilm) {
		boolean r = shortFilmService.deleteById(shortFilm.getId());
		if (r) {
			System.out.println("shortFilm 删除成功>>>" + shortFilm.getId());
		}
	}

	@Override
	public ShortFilmComment saveShortFilmComment(ShortFilmComment shortFilmComment) {
		boolean r = shortFilmCommentService.insert(shortFilmComment);
		if (r) {
			return shortFilmComment;
		}
		return null;
	}

	@Override
	public ShortFilmComment editShortFilmComment(ShortFilmComment shortFilmComment) {
		boolean r = shortFilmCommentService.updateAllColumnById(shortFilmComment);
		if (r) {
			return shortFilmComment;
		}
		return null;
	}

	@Override
	public void deleteShortFilmComment(ShortFilmComment shortFilmComment) {
		boolean r = shortFilmCommentService.deleteById(shortFilmComment.getId());
		if (r) {
			System.out.println("shortFilmComment 删除成功>>>" + shortFilmComment.getId());
		}
	}

	@Override
	public Paper savePaper(Paper paper) {
		boolean r = paperService.insert(paper);
		if (r) {
			return paper;
		}
		return null;
	}

	@Override
	public Paper editPaper(Paper paper) {
		boolean r = paperService.updateAllColumnById(paper);
		if (r) {
			return paper;
		}
		return null;
	}

	@Override
	public void deletePaper(Paper paper) {
		boolean r = paperService.deleteById(paper.getId());
		if (r) {
			System.out.println("paper 删除成功>>>" + paper.getId());
		}
	}

	@Override
	public Answer saveAnswer(Answer answer) {
		boolean r = answerService.insert(answer);
		if (r) {
			return answer;
		}
		return null;
	}

	@Override
	public Answer editAnswer(Answer answer) {
		boolean r = answerService.updateAllColumnById(answer);
		if (r) {
			return answer;
		}
		return null;
	}

	@Override
	public void deleteAnswer(Answer answer) {
		boolean r = answerService.deleteById(answer.getId());
		if (r) {
			System.out.println("answer 删除成功>>>" + answer.getId());
		}
	}

	@Override
	public Audit saveAudit(Audit audit) {
		boolean r = auditService.insert(audit);
		if (r) {
			return audit;
		}
		return null;
	}

	@Override
	public Audit editAudit(Audit audit) {
		boolean r = auditService.updateAllColumnById(audit);
		if (r) {
			return audit;
		}
		return null;
	}

	@Override
	public void deleteAudit(Audit audit) {
		boolean r = auditService.deleteById(audit.getId());
		if (r) {
			System.out.println("audit 删除成功>>>" + audit.getId());
		}
	}

	@Override
	public void deleteLogAll() {
		logMapper.deleteAll();
	}

}
